set(CP_SRCS
	CP_Dialogs.c
)

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   set(CP_SRCS
	${CP_SRCS} CP_Dialogs_OSX.mm
   )

   set(CP_LINKER_FLAGS
       -lobjc
       "-framework CoreData"
       "-framework Foundation"
       "-framework Cocoa"
   )
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

set(CP_HDRS
	CP_Dialogs.h
)


set(CP_Dialogs_install_HDRS
	CP_Dialogs.h
)

set(CP_Dialogs_OUTPUT_NAME "CP_Dialogs")

# Build the shared library (.so or .dll)
if(CP_BUILD_SHARED)
	add_library(CP_Dialogs_shared SHARED
		${CP_HDRS}
		${CP_SRCS}
	)
	set_target_properties(CP_Dialogs_shared PROPERTIES
		OUTPUT_NAME ${CP_Dialogs_OUTPUT_NAME}
		CLEAN_DIRECT_OUTPUT 1
		VERSION ${CP_VERSION}
	)
	set_target_properties(CP_Dialogs_shared PROPERTIES LINKER_LANGUAGE C)
        target_link_libraries(CP_Dialogs_shared ${CP_LINKER_FLAGS})
endif()

# Build the static library (.a)
if(CP_BUILD_STATIC)
	add_library(CP_Dialogs STATIC
		${CP_HDRS}
		${CP_SRCS}
	)
	set_target_properties(CP_Dialogs PROPERTIES
		OUTPUT_NAME ${CP_Dialogs_OUTPUT_NAME}
		CLEAN_DIRECT_OUTPUT 1
		VERSION ${CP_VERSION}
	)
	set_target_properties(CP_Dialogs PROPERTIES LINKER_LANGUAGE C)
        target_link_libraries(CP_Dialogs ${CP_LINKER_FLAGS})
endif()

# These are used to create visual studio folders.
source_group(Common FILES ${CP_SRCS} ${CP_HDRS})

# Install the library
if(CP_INSTALL)
	# install headers
	install(FILES ${CP_Dialogs_install_HDRS} DESTINATION include/SDL)

	# install libraries
	if(CP_BUILD_SHARED)
		install(TARGETS CP_Dialogs_shared EXPORT CP_Dialogs-targets DESTINATION lib)
	endif()
	if(CP_BUILD_STATIC)
		install(TARGETS CP_Dialogs EXPORT CP_Dialogs-targets DESTINATION lib)
	endif()

	# install build system hooks for third-party apps
	#install(EXPORT CP_Dialogs-targets DESTINATION ./build)
	#install(FILES CP_Dialogs_Config.cmake DESTINATION ./build)
endif(CP_INSTALL)
